<template>
	<view>
		<view class="" v-for="(val,key) in list" :key="key">
			<view class="m-h3">
				<text>{{val.title}}</text>
			</view>
			<view class="m-cell-group">
				<view class="m-cell" v-for="(item,index) in val.option" :key="index" @click="selectItemFun(key,item)">
					<view class="m-cell-left">
						<text>{{item.title}}</text>
					</view>
					<view class="m-cell-right">
						<image v-if="selectList[key] == item.title" src="../static/hotel/radio-select.png" mode=""></image>
						<image v-else src="../static/hotel/radio.png" mode=""></image>
					</view>
				</view>
			</view>
		</view>
		
		<view class="m-bottom-empty"></view>
		<view class="m-bottom safe-area-inset-bottom">
			<view class="m-bottom-btn" @click="resetFun">
				<text>重置</text>
			</view>
			<view class="m-bottom-btn m-bottom-btn__extend" @click="submitFun">
				<text>确定</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list:[
					{
						title:'距离电梯',
						option:[{
							title:'远',
						},{
							title:'近',
						},{
							title:'不限',
						}]
					},{
						title:'楼层',
						option:[{
							title:'高',
						},{
							title:'中',
						},{
							title:'低',
						},{
							title:'不限',
						}]
					},{
						title:'朝向',
						option:[{
							title:'朝南',
						},{
							title:'不限',
						}]
					}
				],
				selectList:['不限','不限','不限'],
			}
		},
		methods: {
			selectItemFun(index,{title}){
				let arr = JSON.parse(JSON.stringify(this.selectList))
				arr[index] = title
				this.selectList = arr 
			},
			resetFun(){
				this.selectList = ['不限','不限','不限']
				uni.$emit('selectRuleEmit','不限')
				this.to_back()
			},
			submitFun(){
				let arr = []
				this.selectList.forEach((item,index)=>{
					if(item != '不限'){
						arr.push(`${this.list[index].title}:${item}`)
					}
				})
				uni.$emit('selectRuleEmit',arr.length==0?'不限': arr.join(','))
				this.to_back()
			}
		}
	}
</script>

<style lang="scss">
.m-h3{
	display: flex;
	align-items: center;
	padding: 0 24rpx;
	width: 750rpx;
	height: 76rpx;
	background: #F6F6F6;
	font-size: 26rpx;
}
.m-cell-group{
	padding: 0 24rpx;
	.m-cell{
		display: flex;
		align-items: center;
		justify-content: space-between;
		height: 104rpx;
		border-bottom: 1px solid #DDDDDD;
		.m-cell-left{
			font-size: 28rpx;
			color: #33302D;
		}
		.m-cell-right{
			image{
				width: 30rpx;
				height: 30rpx;
			}
		}
	}
}

.m-bottom-empty{
	width: 100%;
	height: 300rpx;
}
.m-bottom{
	display: flex;
	justify-content: center;
	align-items: center;
	position: fixed;
	bottom: 0rpx;
	width: 750rpx;
	padding-top: 10rpx;
	background: #fff;
	box-shadow: 0rpx -4rpx 10rpx 1rpx rgba(0,0,0,0.06);
	.m-bottom-btn{
		display: flex;
		justify-content: center;
		align-items: center;
		width: 341rpx;
		height: 104rpx;
		background: #FFFFFF;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
		border: 1rpx solid #E6E2DE;
		font-size: 32rpx;
		color: #9B958F;
	}
	.m-bottom-btn__extend{
		background: #D3A358;
		border-color: #D3A358;
		color: #fff;
		margin-left: 20rpx;
	}
}
</style>
